package com.gwq.base;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.gwq.utils.DateUtils;
import com.gwq.utils.StringUtils;
import io.swagger.annotations.ApiModelProperty;

import java.text.ParseException;
import java.util.Date;

public class BaseEntity<T extends Model> extends Model<T> {
    private String id;

    @TableField(fill = FieldFill.INSERT)
    @ApiModelProperty(value = "创建时间", hidden = true, readOnly = true)
    private String createdAt;

    @TableField(fill = FieldFill.INSERT_UPDATE)
    @ApiModelProperty(value = "更新时间", hidden = true, readOnly = true)
    private String updatedAt;

    @TableField(fill = FieldFill.INSERT)
    @ApiModelProperty(value = "创建者", hidden = true, readOnly = true)
    private String createdBy;

    @TableField(fill = FieldFill.INSERT_UPDATE)
    @ApiModelProperty(value = "更新者", hidden = true, readOnly = true)
    private String updatedBy;

    @ApiModelProperty(value = "状态", hidden = true, readOnly = true)
    private Integer status = 1;


    @ApiModelProperty(value = "商户id", hidden = true, readOnly = true)
    private String merchantId;

    public Date getCreatedAt() {
        try {
            if (StringUtils.isEmpty(this.createdAt)){
                return null;
            }
            return DateUtils.stringToDate(this.createdAt);
        } catch (ParseException e) {
            return null;
        }
    }

    public void setCreatedAt(String createdAt) {
        this.createdAt = createdAt;
    }
    public Date getUpdatedAt() {
        try {
            if (StringUtils.isEmpty(this.updatedAt)){
                return null;
            }
            return DateUtils.stringToDate(updatedAt);
        } catch (ParseException e) {
            return null;
        }
    }

    public void setUpdatedAt(String updatedAt) {
        this.updatedAt = updatedAt;
    }

    public String getUpdatedBy() {

        return this.updatedBy;
    }

    public void setUpdatedBy(String updatedBy) {
        this.updatedBy = updatedBy;
    }

    public String getCreatedBy() {
        return this.createdBy;
    }

    public void setCreatedBy(String createdBy) {
        this.createdBy = createdBy;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getMerchantId() {
        return merchantId;
    }

    public void setMerchantId(String merchantId) {
        this.merchantId = merchantId;
    }
}

